/<template>
  <div>
    <Item v-for="(item, index) in list" :key="index" :item="item"></Item>
    <button @click="handleClick">To</button>
  </div>
</template>

<script>
import Item from "@/components/item";
import request from "@/untils/request";
import "@/api/list";
import { mapState, mapActions } from "vuex";
export default {
  components: { Item },
  computed: {
    ...mapState(["list"]),
  },
  created() {
    if (this.list.length == 0) {
      request.get("/api/list").then((res) => {
        this.setMutationData(res.data.list);
      });
    }
  },
  methods: {
    ...mapActions(["setMutationData"]),
    handleClick() {
      this.$router.push("/home/shop");
    },
  },
};
</script>

<style>
</style>